@use "sass:math";

@import '../../../../variables';

$sTopBottom: $s * 0.666666;
$sLeftRight: $sTopBottom * 0.5;
$dragHandleWidth: 24px;
$listControlsWidth: 36px;
$bookmarkMinWidth: 56px;

:host {
  display: block;
  //@include mat-css-color-and-contrast(800);
  .list-controls > button,
  .global-bookmark a {
    background: transparent;
  }
}

.global-bookmark-list-outer {
  padding-bottom: $sTopBottom;
  //box-shadow: $whiteframe-shadow-3dp;
}

.controls-and-list-wrapper {
  display: flex;
  flex-flow: row;
  flex-wrap: nowrap;
}

.list-controls {
  display: flex;
  flex-flow: row;
  flex-wrap: wrap;
  justify-content: stretch;
  align-items: stretch;
  flex: 1;
  flex-shrink: 10;

  @include mq(xxs) {
    flex-wrap: nowrap;
    flex: 0;
  }

  > button {
    display: flex;
    min-width: $listControlsWidth;
    padding-left: 0;
    padding-right: 0;
    text-align: center;

    ::ng-deep .mat-button-wrapper {
      width: 100%;
    }
  }
}

.global-bookmark-list-inner {
  display: flex;
  flex-flow: row;
  justify-content: stretch;
  align-self: center;
  flex-wrap: wrap;
  flex: 10;
}

.msg {
  flex: 1 1 auto;
  display: flex;
  justify-content: center;
  align-content: center;
  align-self: center;
  padding: $s;
  padding-top: $s + $sTopBottom;
}

.list-controls button,
.global-bookmark {
  flex: 1 1 auto;
  margin: $sTopBottom $sLeftRight 0;
  position: relative;

  ::ng-deep mat-icon {
    // center
    margin-top: -3px;
  }

  ::ng-deep .drag-handle {
    margin-top: 0;
  }
}

.global-bookmark-list-inner.isEditMode .global-bookmark {
  > a:focus + .controls,
  &.focus .controls,
  .controls:hover {
    visibility: visible;

    button {
      opacity: 1;
      transition: $transition-enter;
    }

    .edit-btn {
      transform: translate(0, 0);
    }

    .trash-btn {
      transform: translate(0, 0);
    }
  }
}

:host-context(.gu-unselectable) {
  .controls {
    display: none !important;
  }
}

.global-bookmark > a {
  text-decoration: none;
  display: flex;
  align-items: flex-start;
  flex-direction: row;
  justify-content: center;
  text-transform: none;
  background-size: cover;
  background-position: center center;

  // allow them to be smaller to save space
  min-width: $bookmarkMinWidth;
  padding-left: $s;
  padding-right: $s;
}

.global-bookmark.gu-mirror > a {
  box-shadow: $whiteframe-shadow-8dp !important;
}

.controls {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  display: flex;
  flex-direction: row;
  overflow: hidden;
  border-radius: 4px;

  .drag-handle {
    transition: $transition-standard;
    width: $dragHandleWidth;
    height: 100%;
    z-index: 2;
    border-top-left-radius: $card-border-radius;
    border-bottom-left-radius: $card-border-radius;
    box-shadow: $whiteframe-shadow-3dp;
    max-width: 33%;

    // fixes drag and drop on mobile
    touch-action: none;

    @include grabCursor();
  }

  button {
    border-radius: 0;
    flex-grow: 1;
    transition: $transition-duration-s;
    //border-radius: 0;
    margin: 0;
    padding: 0;
    min-height: 0;
    opacity: 1;
    min-width: 20px;
  }
}

.edit-btn {
  @include mq(xs) {
    transform: translate(-100%);
  }
}

.trash-btn {
  @include mq(xs) {
    transform: translate(100%);
  }
}

.drag-over-msg {
  pointer-events: none;
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  bottom: 0;
  justify-content: center;
  align-items: center;
  font-weight: bold;
  display: flex;
  z-index: 15;
}
